<?php

/**
 * Output Api Class
 * @category Util
 * @package V1
 * @author Minh Thai <minhthaind@gmail.com>
 * @license http://mylines.com name
 * @link URL description
 */
class OutputApi
{

    private $_code;
    private $_status;
    private $_message;
    private $_result;
    private $_total;
    /**
     * Construct Function
     */
    public function __construct()
    {
        $this->_code = 0;
        $this->_status = true;
        $this->_message = '';
        $this->_result = null;
        $this->_total = null;
    }

    /**
     * Set Code
     * @param type $code code of Output
     */
    public function setCode($code)
    {
        $this->_code = $code;
    }

    /**
     * Get Code
     * @return type
     */
    public function getCode()
    {
        return $this->_code;
    }

    /**
     * Set Status
     * @param type $status Status of Output
     */
    public function setStatus($status)
    {
        $this->_status = $status;
    }

    /**
     * Get Type
     * @return type
     */
    public function getStatus()
    {
        return $this->_status;
    }

    /**
     * Set Message
     * @param type $msg message of Output
     */
    public function setMessage($msg)
    {
        $this->_message = $msg;
    }

    /**
     * Get message
     * @return type
     */
    public function getMessage()
    {
        return $this->_message;
    }

    /**
     * Set Result
     * @param type $result array reslult
    */
    public function setResult($result) 
    {
        $this->_result = $result;
    }

    /**
     * Get Result
     * @return type
     */
    public function getResult() 
    {
        return $this->_result;
    }

    /**
     * Set Respone Output
     * @param string $status Status Output
     * @param string $code Code Output
     * @param string $msg message output
     * @param string $result array Result
     * @param int $total Total of recodes
     */
    public function setResponse($status, $code, $msg, $result = null, $total = null) 
    {
        if ($status != '')
            $this->_status = $status;
        if ($code != '')
            $this->_code = $code;
        if ($msg != '')
            $this->_message = $msg;
        if ($result != null && $result != '')
            $this->_result = $result;
        if ($total != null && $total != '')
            $this->_total = $total;
    }

    /**
     * Return Array respone
     * @return aray
     */
    public function getRespone() 
    {
        $ret = array();
        $ret['status'] = $this->_status;
        $ret['code'] = $this->_code;
        if ($this->_total != '')
            $ret['total'] = $this->_total;
        if ($this->_message != '')
            $ret['message'] = $this->_message;

        if ($this->_result != null)
            $ret['result'] = $this->_result;
        
        return $ret;
    }

}
